import pygame.sprite

from actor import ActionByMulti

"""
欢迎精灵类
"""


class WelcomeSprite(pygame.sprite.Sprite):
    def __init__(self, x: int, y: int):
        """
        初始化欢迎精灵
        :param x: x坐标
        :param y: y坐标
        """

        super(WelcomeSprite, self).__init__()
        self.action = ActionByMulti("./resources/images/welcome/%d-1.png", 9, True)
        self.pos_x = x
        self.pos_y = y

    def draw(self, surface: pygame.surface, x: int, y: int):
        """
        欢迎精灵绘制到窗口上
        :param surface: 窗口
        :param x: x坐标
        :param y: y坐标
        :return:
        """
        current_image = self.action.get_image()
        surface.blit(current_image, (self.pos_x - x, self.pos_y - y))

    def run(self, down_flag, key_list):
        """
        实现精灵的运动
        :return:
        """
        if self.pos_x < 1280:
            self.pos_x += 5


"""
欢迎精灵类
"""


class WelcomeSpriteFail(WelcomeSprite):

    def __init__(self, x: int, y: int):
        """
        初始化失败欢迎精灵参数
        :param x: x坐标
        :param y: y坐标
        """
        super(WelcomeSprite, self).__init__()
        self.action = ActionByMulti("./resources/images/fail/f_%d.png", 9, True)
        self.pos_x = x
        self.pos_y = y

    def run(self, down_flag, key_list):
        """
        实现人物的移动
        :param down_flag:
        :param key_list:
        :return:
        """
        pass


class WelcomeSpriteWin(WelcomeSprite):
    def __init__(self, x: int, y: int):
        """
        初始化欢迎精灵
        :param x: x坐标
        :param y: y坐标
        """
        super(WelcomeSprite, self).__init__()
        self.action = ActionByMulti("./resources/images/win/w_%d.png", 7, True)
        self.pos_x = x
        self.pos_y = y

    def run(self, down_flag, key_list):
        """
        实现人物的移动
        :param down_flag:按键标志
        :param key_list: 按键列表
        :return:
        """
        pass
